//package com.cgly.medical.handler.security;
//
//import com.cgly.medical.util.Msg;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import org.springframework.security.access.AccessDeniedException;
//import org.springframework.security.web.access.AccessDeniedHandler;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
///**
// * @program: medical
// * @description: 当用户在没有授权的时候，返回的指定信息
// * @author: chen di
// * @create: 2022-08-15 16:29
// */
//@Component
//public class MyAccessDeniedHandler implements AccessDeniedHandler {
//    /**
//     * 当用户向没有权限的接口发送请求时，调用此处理器发送json数据返回前端，提示用户无访问权限，
//     * @param request
//     * @param response
//     * @param accessDeniedException
//     * @throws IOException
//     * @throws ServletException
//     */
//    @Override
//    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
//        response.setContentType("text/json;charset=utf-8");
//        response.getWriter().write(new ObjectMapper().writeValueAsString(Msg.fail().mess("无访问权限").code(10007)));
//    }
//}